import 'package:fish_redux/fish_redux.dart';

enum AnswerListAction {
  onLoad,
  loaded,
  loading,
  listResult,
  onReload,
  onDelete,
  read,
  selectClass,
  onSelectClass,
  deleted,
  classes,
}

class AnswerListActionCreator {
  static Action onLoad() {
    return Action(AnswerListAction.onLoad);
  }

  static Action loading() {
    return Action(AnswerListAction.loading);
  }

  static Action loaded() {
    return Action(AnswerListAction.loaded);
  }

  static Action listResult(List items, var pageTotal, var pageIndex) {
    return Action(AnswerListAction.listResult, payload: {
      'items': items,
      "pageTotal": pageTotal,
      "pageIndex": pageIndex
    });
  }

  static Action onReload(callback) {
    return Action(AnswerListAction.onReload, payload: callback);
  }

  static Action onDelete(int index) {
    return Action(AnswerListAction.onDelete, payload: index);
  }

  static Action deleted(int index) {
    return Action(AnswerListAction.deleted, payload: index);
  }

  static Action read(String id) {
    return Action(AnswerListAction.read, payload: id);
  }

  static Action selectClass(String id) {
    return Action(AnswerListAction.selectClass, payload: id);
  }

  static Action onSelectClass(String item) {
    return Action(AnswerListAction.onSelectClass, payload: item);
  }

  static Action classes(List<dynamic> data) {
    return Action(AnswerListAction.classes, payload: data);
  }
}
